<script>
	$(function () {

		layui.extend({
			dtree: '{/}/static/plugins/layui/extends/dtree/dtree'   // {/}的意思即代表采用自有路径，即不跟随 base 路径
		}).use(['dtree','layer','jquery'], function(){
			var dtree = layui.dtree, layer = layui.layer, $ = layui.jquery;
			
			// 初始化树
			var DemoTree = dtree.render({
				elem: "#id_tree",
				url: '/api/inter/tsUserInfo/dtree',
				initLevel: "2",
				toolbar:true,
				toolbarWay:"follow",
				toolbarShow:[],
				width:'100%',
				menubar:true,
				menubarTips:{
					group:["refresh"]
				},
				toolbarExt: [{
					toolbarId: "add",
					icon: "dtree-icon-add-circle",
					title: "给用户授权机构权限",
					handler: function (node, $div) {
						var content, title, url;
						layer.open({
							type: 2,
							title: "给用户授权机构权限",
							area: ['95%', '90%'],
							content: '/web/sys/tsOrganizationInfo/toAuth?guid=' + node.nodeId
						});
					}
				}]
			});
			
			// 绑定节点点击
			dtree.on("node('id_tree')" ,function(obj){
				var objd = obj.param;
				layui.table.reload("main_table",{
					page: {
						curr: 1 //重新从第 1 页开始
					},
					where: {
						guidTsOrganizationInfo: objd.nodeId
					}
				})
				return;
			});
		});
	});
</script>